<?php

declare(strict_types=1);

namespace app\shop\controller\api\commission;

use app\shop\model\commission\Log as LogModel;
use sheep\library\Operator;

class Log extends Commission
{
    // 分销动态
    public function index()
    {
        $agentId = $this->service->user->id;
        $logs = LogModel::where([
            'agent_id' => $agentId
        ])->with('oper')->order('id desc')->paginate(request()->param('list_rows', 10))->toArray();

        foreach ($logs['data'] as &$log) {
            $log['oper'] = Operator::info($log['oper_type'], $log['oper'] ?? null);
        }

        return success("", $logs);
    }
}
